package cn.dubito.miaosha.service;

import cn.dubito.miaosha.dao.GoodsDao;
import cn.dubito.miaosha.domain.SeckillGoods;
import cn.dubito.miaosha.vo.GoodsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liliang
 * @description:
 * @date 2018/3/31.
 */
@Service
public class GoodsService {

    @Autowired
    private GoodsDao goodsDao;

    public List<GoodsVO> listGoodsVo() {
        return goodsDao.getGoodsList();
    }

    public GoodsVO getGoodsDetailByGoodsId(long goodsId) {
        return goodsDao.getGoodsByGoodsId(goodsId);
    }

    public boolean reduceStock(GoodsVO goods) {
        SeckillGoods g = new SeckillGoods();
        g.setGoodsId(goods.getId());
        int ret = goodsDao.reduceStock(g);
        return ret > 0;
    }
}
